package cn.ldf.keepaccounts.controller;


import cn.ldf.keepaccounts.entity.pojo.GameRecords;
import cn.ldf.keepaccounts.entity.vo.R;
import cn.ldf.keepaccounts.service.GameRecordsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 支付记录表(GameRecords)表控制层
 *
 * @author 清峰
 * @since 2025-02-17 09:37:44
 */
@RestController
@RequestMapping("gameRecords")
public class GameRecordsController {
    /**
     * 服务对象
     */
    @Resource
    private GameRecordsService gameRecordsService;

    /**
     * 添加支付记录
     *
     * @param gameRecords 支付记录
     * @return 结果集
     */
    @PostMapping("/addGameRecords")
    public R<GameRecords> addGameRecords(@Valid @RequestBody GameRecords gameRecords) {
        return R.success(gameRecordsService.addGameRecords(gameRecords));
    }

    /**
     * 获取所以支付记录
     *
     * @param page        分页对象
     * @param gameRecords 查询参数
     * @return 结果集
     */
    @GetMapping("/listPage")
    public R<Page<GameRecords>> listPage(Page<GameRecords> page, GameRecords gameRecords) {
        return R.success(gameRecordsService.page(page, new QueryWrapper<>(gameRecords)));
    }

    /**
     * 根据房间号获取所以支付记录
     *
     * @param roomId 房间号
     * @return 结果集
     */
    @GetMapping("/getListByRoomId")
    public R<List<GameRecords>> getListByRoomId(@RequestParam String roomId) {
        return R.success(gameRecordsService.getListByRoomId(roomId));
    }


}

